
# UNDER CONSTRUCTION

import numpy
import random

class Langevin:

    def __init__(self, speck, potential, T = 300.0, gamma = 0.01, dt = 0.1):
        self.speck = speck
        self.potential = potential
        self.kT = T / 11604.5
        self.gamma = gamma
        self.dt = dt
        speck.v = speck.r * 0.0
        
    def step(self):
        self.potential.force(self.speck)
        f = self.speck.r * 0.0
        for i in range(len(self.speck)):
            rv = numpy.random.normal(size=3)
            rv /= numpy.linalg.norm(rv)
            rv *= numpy.random.normal(0, 1)
            f[i] = self.speck.f[i] - \
                   self.gamma * self.speck.m[i][0] * self.speck.v[i] + \
                   rv * numpy.sqrt(2.0 * self.gamma * self.kT * self.speck.m[i][0])
        self.speck.v += f * self.dt
        self.speck.r += self.speck.v * self.dt
    
